#include "day1.h"
#include <CommonLib/Common/Common.h>
#include <osgGA/StateSetManipulator>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/Viewer>
#include <iostream>

extern osgViewer::Viewer *createViewer();

int day1()
{
    int nType = 0;
    while(nType < 4)
    {
        std::cout << "select scene:" << std::endl;
        std::cout << "1.simple" << std::endl;
        std::cout << "2.model" << std::endl;
        std::cout << "3.keyboard" << std::endl;
        std::cout << "4.quit" << std::endl;
        std::cin >> nType;

        osg::ref_ptr<osgViewer::Viewer> rpViewer = createViewer();
        if (nType == 2 || nType == 3)
        {
            osg::ref_ptr<osg::Node> rpCow = FeCommon::readNode("cow.osg");
            rpViewer->setSceneData(rpCow.get());
        }
        if (nType == 3)
        {
            rpViewer->addEventHandler( new osgViewer::StatsHandler );
            rpViewer->addEventHandler( new osgViewer::WindowSizeHandler );
            rpViewer->addEventHandler( new osgGA::StateSetManipulator(rpViewer->getCamera()->getOrCreateStateSet()));
        }
        if (nType < 4)
        {
            rpViewer->run();
        }
    }
    return 0;
}
